package com.sesxh.project.knowledge.router;

import java.util.Map;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.sesxh.frame.core.data.DataSet;
import com.sesxh.frame.web.controller.BaseController;
import com.sesxh.project.knowledge.biz.model.Attaches;
import com.sesxh.project.knowledge.biz.service.IAttachesService;
@Controller 
@RequestMapping("/knowledge/attaches")
public class AttachesController implements BaseController {

	
	@Autowired
	private IAttachesService attachesService;
	
    @RequestMapping(value="/loadAttachesDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadAttachesDataSet(@RequestParam Map<String,Object> params){
	    DataSet dataSet=  attachesService.loadAttachesDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
	
    @RequestMapping(value="/createAttaches", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public  @ResponseBody Object createAttaches(Attaches attaches){
		attachesService.createAttaches(attaches);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
    @RequestMapping(value="/loadAttaches", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadAttaches(Long id){
		Optional<Attaches> ops = attachesService.loadAttachesById(id);
		return ajaxQuery("attaches",ops);
    }
	
    @RequestMapping(value="/updateAttaches", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object updateAttaches(Attaches attaches){
		attachesService.updateAttaches(attaches);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
    @RequestMapping(value="/deleteAttaches", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object deleteAttaches(Long id){
		attachesService.deleteAttaches(id);
		return ajaxDoneSuccess("数据操作成功 ");
    }

}